package org.yanfengying.org.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.yanfengying.org.service.IFsatdflService;
import org.yanfengying.utils.FastdfsUtil;

@Service
public class FsatdflServiceImpl implements IFsatdflService {
    @Value("${fastdfs.url}")
    private String fastdfsUrl;
    @Override
    public String getPath(byte[] bytes, String extName) {
        String path = fastdfsUrl + FastdfsUtil.upload(bytes, extName);
        return path;
    }

    @Override
    public void delLogo(String path) {
        String path1 = path.substring(fastdfsUrl.length() + 1);
        int i = path1.indexOf("/");
        String group = path1.substring(0, i);
        String fastdsfPath = path1.substring(i + 1, path1.length());
        FastdfsUtil.delete(group, fastdsfPath);
    }
}
